<?php

namespace app\api\controller\v1;

use addons\litestore\model\Litestoregoodsspec;
use addons\litestore\model\Wxlitestoregoods;
use app\admin\model\litestore\Litestoregoods;
use app\admin\model\litestore\Litestorenews;

use app\admin\model\unilive\Room;
use app\common\controller\Api;

/**
 */
class Live extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];



    public function index(){

        $where = array();
        $page = $this->request->param('page');
        $status = $this->request->param('status');

        if($status == 0){
            $where['live_status'] = ['in',['102','101','107']];
        }else {
            $where['live_status'] = '103';
        }


        $limit = 10;
        $offset = ($page - 1) * $limit;
        $room = new Room();
        $list =$room
            ->where($where)
            ->limit($offset, $limit)
            ->select();
        foreach ($list as $key=>$val){
            $list[$key]['cover_img'] = cdnurl($val['cover_img'],true);
            $list[$key]['start'] = date('Y-m-d h:i:s',$val['start_time']);
            if($val['live_status'] == '101'){
                $list[$key]['status'] = '直播中';
            }else if($val['live_status'] == '102'){
                $list[$key]['status'] = '未开始';
            }else if($val['live_status'] == '103'){
                $list[$key]['status'] = '已结束';
            }else if($val['live_status'] == '107'){
                $list[$key]['status'] = '已过期';
            }
        }
        $this->success('',$list);
    }



}
